package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        try {
            System.out.println("程序开始了");
            String str =  null;
            System.out.println(str.length());
            System.out.println("程序结束了");
        }catch (NullPointerException e){
            System.out.println("空指针异常，处理完毕了");
        }
    }
}
//catch可以定义多个，针对不同